home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SAMPLES.BIN / Animation.java < prev    next >
Encoding:
Java Source  |  1996-12-03  |  3.5 KB  |  131 lines

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. public class Animation extends Frame {
  8.     void start_Clicked(Event event) {
  9.  
  10.  
  11.         //{{CONNECTION
  12.         // Start the animation
  13.         {
  14.             animator1.startAnimation();
  15.         }
  16.         //}}
  17.     }
  18.  
  19.     void Stop_Clicked(Event event) {
  20.  
  21.  
  22.         //{{CONNECTION
  23.         // Stop the animation
  24.         {
  25.             animator1.stopAnimation();
  26.         }
  27.         //}}
  28.     }
  29.  
  30.     void close_Clicked(Event event) {
  31.  
  32.  
  33.         //{{CONNECTION
  34.         // Hide the Frame
  35.         hide();
  36.         //}}
  37.     }
  38.  
  39.  
  40.     public Animation() {
  41.  
  42.         //{{INIT_CONTROLS
  43.         setLayout(null);
  44.         addNotify();
  45.         resize(insets().left + insets().right + 426,insets().top + insets().bottom + 264);
  46.         setBackground(new Color(16776960));
  47.         animator1 = new symantec.itools.multimedia.Animator();
  48.         animator1.reshape(insets().left + 37,insets().top + 10,352,87);
  49.         add(animator1);
  50.         animator1.setDelay(250);
  51.         animator1.setNumLoops(1);
  52.         animator1.setRepeatMode(true);
  53.         try {
  54.             java.net.URL[] tempURL = new java.net.URL[15];
  55.             tempURL[0] = symantec.itools.net.RelativeURL.getURL("images/FN0.gif");
  56.             tempURL[1] = symantec.itools.net.RelativeURL.getURL("images/FN1.gif");
  57.             tempURL[2] = symantec.itools.net.RelativeURL.getURL("images/FN2.gif");
  58.             tempURL[3] = symantec.itools.net.RelativeURL.getURL("images/FN3.gif");
  59.             tempURL[4] = symantec.itools.net.RelativeURL.getURL("images/FN4.gif");
  60.             tempURL[5] = symantec.itools.net.RelativeURL.getURL("images/FN5.gif");
  61.             tempURL[6] = symantec.itools.net.RelativeURL.getURL("images/FN6.gif");
  62.             tempURL[7] = symantec.itools.net.RelativeURL.getURL("images/FN7.gif");
  63.             tempURL[8] = symantec.itools.net.RelativeURL.getURL("images/FN8.gif");
  64.             tempURL[9] = symantec.itools.net.RelativeURL.getURL("images/FN9.gif");
  65.             tempURL[10] = symantec.itools.net.RelativeURL.getURL("images/FN10.gif");
  66.             tempURL[11] = symantec.itools.net.RelativeURL.getURL("images/FN11.gif");
  67.             tempURL[12] = symantec.itools.net.RelativeURL.getURL("images/FN12.gif");
  68.             tempURL[13] = symantec.itools.net.RelativeURL.getURL("images/FN13.gif");
  69.             tempURL[14] = symantec.itools.net.RelativeURL.getURL("images/FN14.gif");
  70.             animator1.setImageList(tempURL);
  71.         } catch (java.net.MalformedURLException error) {
  72.         }
  73.         animator1.setClearFrame(false);
  74.         animator1.setPreviewMode(true);
  75.         Stop = new java.awt.Button("Stop the Animation");
  76.         Stop.reshape(insets().left + 145,insets().top + 216,138,24);
  77.         add(Stop);
  78.         start = new java.awt.Button("Re-Start the Animation");
  79.         start.reshape(insets().left + 287,insets().top + 216,138,24);
  80.         add(start);
  81.         close = new java.awt.Button("Close");
  82.         close.reshape(insets().left + 3,insets().top + 216,138,24);
  83.         add(close);
  84.         setTitle("Untitled");
  85.         //}}
  86.  
  87.         //{{INIT_MENUS
  88.         //}}
  89.     }
  90.  
  91.     public Animation(String title) {
  92.         this();
  93.         setTitle(title);
  94.     }
  95.  
  96.     public synchronized void show() {
  97.         move(50, 50);
  98.         super.show();
  99.     }
  100.  
  101.     public boolean handleEvent(Event event) {
  102.         if (event.id == Event.WINDOW_DESTROY) {
  103.             hide();         // hide the Frame
  104.             return true;
  105.         }
  106.         if (event.target == close && event.id == Event.ACTION_EVENT) {
  107.             close_Clicked(event);
  108.             return true;
  109.         }
  110.         if (event.target == Stop && event.id == Event.ACTION_EVENT) {
  111.             Stop_Clicked(event);
  112.             return true;
  113.         }
  114.         if (event.target == start && event.id == Event.ACTION_EVENT) {
  115.             start_Clicked(event);
  116.             return true;
  117.         }
  118.         return super.handleEvent(event);
  119.     }
  120.  
  121.     //{{DECLARE_CONTROLS
  122.     symantec.itools.multimedia.Animator animator1;
  123.     java.awt.Button Stop;
  124.     java.awt.Button start;
  125.     java.awt.Button close;
  126.     //}}
  127.  
  128.     //{{DECLARE_MENUS
  129.     //}}
  130. }
  131.